<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        v-model="form"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
        :permission="permissionList">
        <template slot="menuLeft">
          <el-upload
                  class="upload-inline"
                  action=""
                  :show-file-list="false"
                  accept=".xls,.xlsx"
                  :http-request="handleImport">
                  <el-button type="primary" size="small">导入</el-button>
          </el-upload>
        </template>
        <template slot="priceAreaSearch" slot-scope="{row}">
          <el-input-number style="width: 100%;" v-model="priceArea"></el-input-number>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import baseCrud from '@/mixins/base-crud'
import {saveBatch} from '@/api/support/swparamreceipt'
export default {
  name: 'swparamreceipt',
  mixins: [baseCrud('support/swparamreceipt')],
  data() {
    return {
      priceArea: undefined
    }
  },
  computed: {
    permissionList() {
      return {
        addBtn: this.vaildData(this.permissions.support_sw_param_receipt_add, false),
        delBtn: this.vaildData(this.permissions.support_sw_param_receipt_del, false),
        editBtn: this.vaildData(this.permissions.support_sw_param_receipt_edit, false)
      };
    }
  },
  methods: {
    handleImport(item){
              let file = item.file
              let param = new FormData()
              param.append('file',file)
              saveBatch(param).then(() => {
                this.$notify({
                  title: '成功',
                  message: '导入成功',
                  type: 'success',
                  duration: 2000
                })
                this.getList(this.page)
              })
            },
    searchChange(form, done) {
      for(let key of Object.keys(form)){
        if(this.validatenull(form[key])){
          delete form[key]
        }
      }
      if(!done){
        this.priceArea = undefined
      }
      this.searchForm = form
      this.searchForm.priceArea = this.priceArea
      this.page.currentPage = 1
      this.getList(this.page).then(() => {
        if(done){
          done()
        }
      })
    }
  }
}
</script>
